﻿/*
 Author:du
 Time:2017.11.23
*/

using System;
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public class DLLCompileTool
{
    private const string compiledKey = "Compiled";
    private static bool isCompiled;

    static DLLCompileTool()
    {
        isCompiled = EditorPrefs.GetBool(compiledKey, false);
        EditorApplication.update += Update;
    }

    private static void Update()
    {
        if (isCompiled && !EditorApplication.isCompiling)
        {
            Debug.Log(string.Format("DLLCompile End: {0}", DateTime.Now));
            isCompiled = false;
            EditorPrefs.SetBool(compiledKey, false);
        }
        else if (!isCompiled && EditorApplication.isCompiling)
        {
            Debug.Log(string.Format("DLLCompile Start: {0}", DateTime.Now));
            isCompiled = true;
            EditorPrefs.SetBool(compiledKey, true);
        }
    }
}